package com.scsj.supermarket.adapter;


import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scsj.supermarket.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 店铺关注
 */

public class FollowShopAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mContext;
    public static int DYNAMIC = 0;//排列方式 0 动态
    public static int LIST = 1;//排列方式  1 列表
    private int arrayType = LIST;//排列方式 0 动态 1 列表

    public FollowShopAdapter(Context mContext) {
        super(R.layout.item_follow_shop_list);
        this.mContext = mContext;
    }

    @Override
    protected void convert(final BaseViewHolder helper, final String item) {
            helper.setText(R.id.name_tv, item);

        if(arrayType==DYNAMIC){

        }else {
            RecyclerView sign_rv = helper.getView(R.id.sign_rv);
            sign_rv.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false));
            List<String> list = new ArrayList<>();
            if (item.equals("益联益家")){
                list.add("信用认证");
                list.add("实力认证");
            }else  if (item.equals("Apple产品专营店")){
                list.add("上新");
                list.add("促销");
                list.add("券");
            }else  if (item.equals("幸运叶子旗舰店")){
                list.add("上新");
                list.add("促销");
                list.add("券");
                list.add("专题");
            }
            FollowShopSignAdapter followShopSignAdapter = new FollowShopSignAdapter(mContext,list);
            sign_rv.setAdapter(followShopSignAdapter);
        }
    }

    @Override
    public View getViewByPosition(int position, int viewId) {
        if(arrayType==DYNAMIC){
            viewId = R.layout.item_follow_shop_dynamic;
        }else {
            viewId = R.layout.item_follow_shop_list;
        }
        return super.getViewByPosition(position, viewId);
    }
}
